home *** CD-ROM | disk | FTP | other *** search
- /* NSRange.h
- Definitions relative to ranges
- Copyright 1993, 1994, NeXT, Inc.
- NeXT, Nov 1993
- */
-
- #import <foundation/NSObject.h>
-
- @class NSString;
-
- /* An open struct for specifying a range of items in arrays, strings, etc. */
- typedef struct _NSRange {
- unsigned int location;
- unsigned int length;
- } NSRange;
-
-
- static inline unsigned NSMaxRange(NSRange range) {
- /* Note that this can easily overflow if range.length big */
- return range.location + range.length;
- }
-
- static inline BOOL NSLocationInRange(unsigned location, NSRange range) {
- return (location >= range.location) && (location < NSMaxRange(range));
- }
-
- extern NSRange NSUnionRange(NSRange range1, NSRange range2);
-
- extern NSRange NSIntersectionRange(NSRange range1, NSRange range2);
- /* !length => ranges don't intersect, and then location is meaningless */
-
- extern NSString *NSStringFromRange(NSRange range);
- /* Returns a string of the form: {location = 34; length = 12} */
-